package ac.svn.accesscontrol.ui;

import java.awt.Component;

import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JList;
import javax.swing.ListCellRenderer;

import ac.svn.accesscontrol.store.AccessUnit;
import ac.svn.accesscontrol.utils.Utility;

public class AccessListCellRenderer extends AccessUnitListCell implements
		ListCellRenderer {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public AccessListCellRenderer() {
		super();
		
	}

	@Override
	public Component getListCellRendererComponent(JList arg0, Object value,
			int arg2, boolean isSelected, boolean arg4) {
		
		AccessUnit accessUnit = (AccessUnit) value;
		setTitle(accessUnit.getOwnerId());
		setSelected(isSelected);
		setAccess(accessUnit.isReadEnabled(),accessUnit.isWriteEnabled());
		Icon icon = new ImageIcon(Utility.getImage("images/access.png"));
		setIcon(icon);		
		return this;
	}

}
